package com.epam.rd.my_classLoader;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {

	public static void main(String[] args) throws IOException {
		Thread myThready1 = new Thread(new Runnable()
        {
            public void run() 
            {
            	new Watcher().scanFolder(".");;
            }
        });
		
		Thread myThready2 = new Thread(new Runnable()
        {
            public void run() 
            {
            	for (;;) {		
        			ClassLoader loader = new DynamicClassOverloader(new String[] { "." });
        			Class clazz;
        			Object object;
        			try {
        				clazz = Class.forName("TestModule", true, loader);
        				object = clazz.newInstance();
        				System.out.println(object);
        			} catch (IllegalAccessException | InstantiationException | ClassNotFoundException e) {
        				e.printStackTrace();
        			}
        			try {
        				new BufferedReader(new InputStreamReader(System.in)).readLine();
        			} catch (IOException e) {
        				e.printStackTrace();
        			}
        		}
            }
        });
		
	        myThready1.start();
	        myThready2.start();
	}

}
